home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-tasoli.ads < prev    next >
Text File  |  1996-01-30  |  5KB  |  99 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --            S Y S T E M . T A S K I N G _ S O F T _ L I N K S             --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  This package contains a set of subprogram access variables that access
  27. --  some basic tasking primitives that are called from non-tasking code (e.g.
  28. --  the defer/undefer abort that surrounds a finalization action). To avoid
  29. --  dragging in the tasking all the time, we use a system of soft links where
  30. --  the links are initialized to dummy non-tasking versions, and then if the
  31. --  tasking is initialized, they are reset to the real tasking versions.
  32.  
  33. package System.Tasking_Soft_Links is
  34.  
  35.    --  First we have the access subprogram types used to establish the links.
  36.    --  The approach is to establish variables containing access subprogram
  37.    --  values which by default point to dummy no tasking versions of routines.
  38.  
  39.    --  Note: the reason that Get_Address_Call has a dummy parameter is that
  40.    --  there is a bug in GNAT with access to subprograms with no params ???
  41.  
  42.    type No_Param_Proc    is access procedure;
  43.    type Get_Address_Call is access function (Dummy : Boolean) return Address;
  44.  
  45.    type Proc_SS1 is access procedure (X : Address);
  46.    type Proc_SS2 is access procedure (X : out Address; Y : Integer);
  47.  
  48.    --  Declarations for the no tasking versions of the required routines
  49.  
  50.    procedure Abort_Defer_NT;
  51.    --  Defer task abortion (non-tasking case, does nothing)
  52.  
  53.    procedure Abort_Undefer_NT;
  54.    --  Undefer task abortion (non-tasking case, does nothing)
  55.  
  56.    procedure Task_Lock_NT;
  57.    --  Lock out other tasks (non-tasking case, does nothing)
  58.  
  59.    procedure Task_Unlock_NT;
  60.    --  Release lock set by Task_Lock (non-tasking case, does nothing)
  61.  
  62.    procedure SS_Init_NT (Stk : out Address; Size : Natural);
  63.    --  Initialization of the secondary stack (if no sec-stack does nothing)
  64.  
  65.    procedure SS_Free_NT (Stk : Address);
  66.    --  Release the secondary stack (if no sec-stack does nothing)
  67.  
  68.    function Get_TSD_Address_NT (Dummy : Boolean) return Address;
  69.    --  Obtain pointer to TSD (non-tasking case, gets special global TSD that
  70.    --  is allocated and initialized by the System.Task_Specific_Data package)
  71.  
  72.    Abort_Defer : No_Param_Proc := Abort_Defer_NT'Access;
  73.    --  Defer task abortion (task/non-task case as appropriate)
  74.  
  75.    Abort_Undefer : No_Param_Proc := Abort_Undefer_NT'Access;
  76.    --  Undefer task abortion (task/non-task case as appropriate)
  77.  
  78.    Get_TSD_Address : Get_Address_Call := Get_TSD_Address_NT'Access;
  79.    --  Get pointer to task specific data  (task/non-task case as appropriate)
  80.  
  81.    Lock_Task : No_Param_Proc := Task_Lock_NT'Access;
  82.    --  Locks out other tasks. Preceding a section of code by Task_Lock and
  83.    --  following it by Task_Unlock creates a critical region. This is used
  84.    --  for ensuring that a region of non-tasking code (such as code used to
  85.    --  allocate memory) is tasking safe. Note that it is valid for calls to
  86.    --  Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
  87.    --  only the corresponding outer level Task_Unlock will actually unlock.
  88.  
  89.    Unlock_Task : No_Param_Proc := Task_Unlock_NT'Access;
  90.    --  Releases lock previously set by call to Lock_Task. In the nested case,
  91.    --  all nested locks must be released before other tasks competing for the
  92.    --  tasking lock are released.
  93.  
  94.    SS_Init : Proc_SS2 := SS_Init_NT'Access;
  95.  
  96.    SS_Free : Proc_SS1 := SS_Free_NT'Access;
  97.  
  98. end System.Tasking_Soft_Links;
  99.